package steps
{
	import jnBase.BaseZhishi;
	import jnBase.Data;
	import jnBase.InsPages;
	import jnBase.PSteps;
	
	import laya.utils.Handler;
	import laya.utils.Tween;
	
	import ui.steps.step1_meilanUI;
	
	public class Step01_MeiLan extends step1_meilanUI implements InsPages
	{
		public var _scriptPage:PSteps;
		public var _scriptZhishi:BaseZhishi;
		private var zhishiStr:String="";
		public function Step01_MeiLan()
		{
			super();
			size(1920,1080);
			this.name="1.眉栏";
			_scriptPage=this.addComponent(PSteps);
			_scriptZhishi=this.addComponent(BaseZhishi);
		}
		public function changeSonStep():void
		{
			switch(Data.currSonStep)
			{
				case 0:
				{
					step1();
					break;
				}
				case 1:
				{
					step2();
					break;
				}
				case 2:
				{
					step3();
					break;
				}
				case 3:
				{
					step4();
					break;
				}
				default:
				{
					break;
				}
			}
		}	

		private function step1():void
		{
			tiwendan.pos(1920,226);
			sname.alpha=age.alpha=sex.alpha=number.alpha=department.alpha=date.alpha=0;
			date1.alpha=date2.alpha=date3.alpha=date4.alpha=date5.alpha=date6.alpha=date7.alpha=0;
			day1.alpha=day2.alpha=day3.alpha=day4.alpha=day5.alpha=day6.alpha=day7.alpha=0;
			oper1.alpha=oper2.alpha=oper3.alpha=oper4.alpha=oper5.alpha=oper6.alpha=0;
			_scriptZhishi.showTips("用蓝(黑)钢笔依次填写病人姓名、年龄、性别、科别、床号、入院日期及住院病历号等项目");
			Tween.to(tiwendan,{x:488,y:226},300,null,Handler.create(this,function():void{
				Laya.timer.once(4000,this,function():void{
					Tween.to(sname,{alpha:1},200);
					Tween.to(age,{alpha:1},500);
					Tween.to(sex,{alpha:1},900);
					Tween.to(number,{alpha:1},1300);
					Tween.to(department,{alpha:1},1700);
					Tween.to(date,{alpha:1},2100,null,Handler.create(this,function():void{
						Laya.timer.once(2000,this,function():void{
							_scriptPage.showSonStepByIndex(1);
						});
						
					}));
				});			
			}));
		}
		private function step2():void
		{
			sname.alpha=age.alpha=sex.alpha=number.alpha=department.alpha=date.alpha=1;
			date1.alpha=date2.alpha=date3.alpha=date4.alpha=date5.alpha=date6.alpha=date7.alpha=0;
			day1.alpha=day2.alpha=day3.alpha=day4.alpha=day5.alpha=day6.alpha=day7.alpha=0;
			oper1.alpha=oper2.alpha=oper3.alpha=oper4.alpha=oper5.alpha=oper6.alpha=0;
			_scriptZhishi.showTips("填写“日期”栏时，每页第一天应填写年、月、日，其余六天只写日");
			Laya.timer.once(2000,this,function():void{
				_scriptZhishi.xiankuangClick(641,494,106,48,function():void{
					_scriptZhishi.clearLoop();
					_scriptZhishi.hideAllZhishi();
					Tween.to(date1,{alpha:1},400,null,Handler.create(this,function():void{
						Tween.to(date2,{alpha:1},600);
						Tween.to(date3,{alpha:1},1000);
						Tween.to(date4,{alpha:1},1400);
						Tween.to(date5,{alpha:1},1800,null,Handler.create(this,function():void{
							_scriptZhishi.showTips("如在七天中遇到新的年度或月份开始，则应填写年、月、日或月、日");
							_scriptZhishi.xiankuangClick(1171,494,106,48,function():void{
								_scriptZhishi.clearLoop();
								_scriptZhishi.hideAllZhishi();
								Tween.to(date6,{alpha:1},600);
								Tween.to(date7,{alpha:1},1000,null,Handler.create(this,function():void{
									Laya.timer.once(2000,this,function():void{
										_scriptPage.showSonStepByIndex(2);
									});
								}));
							});
						}));
					}));
				});
			});
		}
		private function step3():void
		{
			// TODO Auto Generated method stub
			sname.alpha=age.alpha=sex.alpha=number.alpha=department.alpha=date.alpha=1;
			date1.alpha=date2.alpha=date3.alpha=date4.alpha=date5.alpha=date6.alpha=date7.alpha=1;
			day1.alpha=day2.alpha=day3.alpha=day4.alpha=day5.alpha=day6.alpha=day7.alpha=0;
			oper1.alpha=oper2.alpha=oper3.alpha=oper4.alpha=oper5.alpha=oper6.alpha=0;
			_scriptZhishi.showTips("住院天数应从病人入院当天为第一天开始填写，直至出院");
			_scriptZhishi.xiankuangClick(642,541,106,48,function():void{
				_scriptZhishi.clearLoop();
				_scriptZhishi.hideAllZhishi();
				Tween.to(day1,{alpha:1},600);
				Tween.to(day2,{alpha:1},1000);
				Tween.to(day3,{alpha:1},1400);
				Tween.to(day4,{alpha:1},1800);
				Tween.to(day5,{alpha:1},2200);
				Tween.to(day6,{alpha:1},2600);
				
				Tween.to(day7,{alpha:1},3000,null,Handler.create(this,function():void{
					Laya.timer.once(2000,this,function():void{
						_scriptPage.showSonStepByIndex(3);
					});
				}));
			});
		}
		private function step4():void
		{
			// TODO Auto Generated method stub
			sname.alpha=age.alpha=sex.alpha=number.alpha=department.alpha=date.alpha=1;
			date1.alpha=date2.alpha=date3.alpha=date4.alpha=date5.alpha=date6.alpha=date7.alpha=1;
			day1.alpha=day2.alpha=day3.alpha=day4.alpha=day5.alpha=day6.alpha=day7.alpha=1;
			oper1.alpha=oper2.alpha=oper3.alpha=oper4.alpha=oper5.alpha=oper6.alpha=0;
			_scriptZhishi.showTips("填写“手术(分娩)后天数”栏时，用红钢笔填写，以手术(分娩)次日为第一日，依次填写至第十四天为止");
			_scriptZhishi.xiankuangClick(748,587,106,48,function():void{
				_scriptZhishi.clearLoop();
				_scriptZhishi.hideAllZhishi();
				Tween.to(oper1,{alpha:1},600);
				Tween.to(oper2,{alpha:1},1000);
				Tween.to(oper3,{alpha:1},1400,null,Handler.create(this,function():void{
					_scriptZhishi.showTips("若在十四天内进行第二次手术，则将第一次手术日数作为分母，第二次手术日数作为分子进行填写");
					_scriptZhishi.xiankuangClick(1065,587,106,48,function():void{
						_scriptZhishi.clearLoop();
						_scriptZhishi.hideAllZhishi();
						Tween.to(oper4,{alpha:1},600);
						Tween.to(oper5,{alpha:1},1000);
						Tween.to(oper6,{alpha:1},1400,null,Handler.create(this,function():void{
							Laya.timer.once(2000,this,function():void{
								_scriptPage.addPage(1);
							});
						}));
					});
				}));
				
			});
		}
		/**
		 *切换二级菜单时自动调用
		 * 显示新的二级页面时会自动调用此方法 
		 * 
		 */		
		public function reset():void
		{
			_scriptZhishi.hideAll();
			removeAllListener();
			zhishiStr="";
			
		}
		/**
		 *移除所有监听 
		 * 
		 */		
		public function removeAllListener():void
		{
			_scriptZhishi.removeAllHandler();	
		}
		override public function onEnable():void{
			reset();
		}
		/**
		 *关闭时自动调用 
		 * @param type
		 * 
		 */		
		override public function close(type:String=null):void
		{
			// TODO Auto Generated method stub
			_scriptPage.enabled=false;
			_scriptZhishi.enabled=false;
			removeAllListener();
			Tween.to(this,{x:-GameConfig.width,alpha:0},300,null,Handler.create(this,closeSuper,[type]));
		}
		private function closeSuper(type:String=null):void{
			super.close(type);
		}
		/**
		 *每秒执行一次 
		 * 
		 */		
		public function lineLoop():void
		{
			// TODO Auto Generated method stub
			if(zhishiStr==""){
				_scriptZhishi.zhishiRect.alpha=1;
				Tween.to(_scriptZhishi.zhishiRect,{alpha:0.1},600);
			}
			else if(zhishiStr=="xi"){
				_scriptZhishi.mdown.visible=true;
				_scriptZhishi.mdown.pos(958,688);
				_scriptZhishi.mdown.rotation=-155;
				Tween.to(_scriptZhishi.mdown,{x:990,y:596},600);
			}
		}
		/**
		 *被移除时自动调用  
		 * 因为设置了自动销毁，所以关闭后后会执行销毁 ，因为关闭时加了一个动画，所以要300毫秒后才执行销毁
		 * 
		 */		
		override public function onDestroy():void{
			trace(this.name+"销毁");
		}
	}
}